package com.jic.manager.controller.manage.conf;

import com.jic.common.base.vo.RestResult;
import com.jic.conf.request.AddCmsModuleRequest;
import com.jic.conf.request.AddCmsPageRequest;
import com.jic.conf.request.AddModuleDataRequest;
import com.jic.conf.request.CmsModuleTemplateQuery;
import com.jic.conf.request.GetModuleCmsConfRequest;
import com.jic.conf.request.SectionMobileRequest;
import com.jic.conf.request.rest.GetCmsProductListRequest;
import com.jic.conf.response.rest.CmsGetIndexPageConfResponse;
import com.jic.conf.response.rest.GetCmsProductListResponse;
import com.jic.conf.response.rest.PageModuleResponse;
import com.jic.manager.entity.CmsModuleTemplate;
import com.jic.manager.service.CmsModuleService;
import com.jic.manager.service.CmsPageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wwb
 */
@RestController
@Api(tags = "后台-CMS")
@RequestMapping(value = "/cmsPageModule")
public class CmsPageModuleController {
    @Resource
    private CmsModuleService cmsModuleService;
    @Resource
    private CmsPageService cmsPageService;

    @ApiOperation("保存页面配置")
    @PostMapping(value = "/addPage")
    public RestResult<String> addPage(@RequestBody AddCmsPageRequest addCmsModuleRequest){
        return cmsPageService.addPage(addCmsModuleRequest);
    }

    @ApiOperation("新增栏目")
    @PostMapping(value = "/addModule")
    public RestResult<PageModuleResponse> addModule(@RequestBody AddCmsModuleRequest addCmsModuleRequest){
       return cmsModuleService.addModule(addCmsModuleRequest);
    }

    @ApiOperation("删除栏目配置")
    @PostMapping(value = "/deleteModule")
    public RestResult<String> deleteModule(@RequestBody SectionMobileRequest sectionMobileRequest){
        return cmsModuleService.deleteModule(sectionMobileRequest);
    }

    @ApiOperation("保存栏目配置")
    @PostMapping(value = "/addModuleData")
    public RestResult<String> addModuleData(@RequestBody AddModuleDataRequest addModuleDataRequest){
        return cmsModuleService.addModuleData(addModuleDataRequest);
    }

    @ApiOperation("栏目上下移动")
    @PostMapping(value = "/sectionMobile")
    public RestResult<String> sectionMobile(@RequestBody SectionMobileRequest sectionMobileRequest){
        return cmsModuleService.sectionMobile(sectionMobileRequest);
    }

    @ApiOperation(value = "查询栏目配置")
    @PostMapping(value = "/getModuleCmsConf")
    public RestResult<CmsGetIndexPageConfResponse> getModuleCmsConf(@RequestBody GetModuleCmsConfRequest getModuleCmsConfRequest) {
        return cmsModuleService.getModuleCmsConf(getModuleCmsConfRequest);
    }


    @ApiOperation(value = "查询具体某个栏目的配置")
    @PostMapping(value = "/getCmsModuleTemplate")
    public RestResult<CmsModuleTemplate> getCmsModuleTemplate(@RequestBody CmsModuleTemplateQuery request) {
        return cmsModuleService.getCmsModuleTemplate(request);
    }

    @ApiOperation(value = "查询栏目商品list")
    @PostMapping(value = "/getCmsProductList")
    public RestResult<List<GetCmsProductListResponse>> getCmsProductList(@RequestBody GetCmsProductListRequest getCmsProductListRequest) {
        return cmsModuleService.getCmsProductList(getCmsProductListRequest);
    }
}
